import * as constants from './constants';
import { fromJS } from 'immutable';
import { Conf } from '../../../utils';

const defaultState=fromJS({
    list:[],
    loading:true,
    total:0,
    emptyText:'暂无数据',
    page:1,
    pageSize:Conf.page_Conf.pageSize,
    formData:{
        arr:['name','description','start_time','end_time']
        ,name:{type:'input',title:'表单名称',name:'name',autoFocus:true,placeholder:"请输入表单名称",rules:[{
            required: true,
            whitespace: true,
            message: '表单名称不能为空'
        }]}
        ,description:{type:'text',title:'描述',rows:4,name:'description'}
        ,start_time:{type:'input.month',title:'开始时间',name:'start_time',placeholder:"请选择时间"}
        ,end_time:{type:'input.month',title:'结束时间',name:'end_time',placeholder:"请选择时间"}
    }
});
export default (state=defaultState,action)=>{
    switch (action.type) {
        case constants.LIST:
            return state.merge({
                list : fromJS(action.list),
                total : action.total
            })
        case constants.LOADING:
            return state.merge({
                loading : action.loading
            })
        case constants.NOAUTH:
            return state.merge({
                emptyText : action.emptyText
            })
            
        case constants.PAGESIZE:
            return state.merge({
                pageSize : action.pageSize
            })
        case constants.PAGE:
            return state.merge({
                page : action.page
            })
        default:
            break;
    }
    return state;
}